<template>
    <div>
        <!--table列表-->
        <el-table :data="tableData" style="width: 100%" height="450" :row-class-name="tableRowClassName">
            <el-table-column  prop="itemCode" label="图号"  width="280"> </el-table-column>
            <el-table-column  prop="itemQty" label="库存数量"  width="180"> </el-table-column>
            <el-table-column  prop="singleQty" label="单机数量"  width="180"> </el-table-column>
            <el-table-column  prop="requiredQty" label="架次数量"  width="180"> </el-table-column>
            <el-table-column  prop="mProductNumber" label="型号"  > </el-table-column>
            <el-table-column  prop="qualityCode" label="质量编号/件号" > </el-table-column>
        </el-table>
        <!--分页-->
        <el-pagination @size-change="handleSizeChange"  @current-change="handleCurrentChange"
            :current-page="page.currentPage"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="1"
            layout="total, sizes, prev, pager, next, jumper"
            :total="page.total">
    </el-pagination>
    </div>
</template>
<script>
import request from "@/utils/request.js";
export default {
    data() {
      return {
        tableData:[],
        page:{
            total:0,
            pageSize:10,
            currentPage:1
        },
        queryParam:{
            productCode: "",
            itemCode: "",
            mProductNumber:"",
            qualityCode:"",
            lotNum:1
        }
      }
    },
    //方法
    methods: {
        handleSizeChange(val) {
            this.page.pageSize = val;
        },
        handleCurrentChange(val) {
            this.page.currentPage = value;
        },
        tableRowClassName({row, rowIndex}) {
            //row.itemQty
            if (rowIndex === 1) {
            return 'warning-row';
            } else if (rowIndex === 3) {
            return 'success-row';
            }
            return '';
        },
        //查询表格数据
        query(){
            console.log("执行查询");
            console.log(this.page);
            console.log(this.queryParam);
            var that = this;
            //需要补全
            request.post("/WmsItemInventorySearch/searchSingleQty",{"pageParameter":this.page,"searchParams":this.queryParam}).then((res)=>{
                console.log("res",res);
                that.tableData = res.data.responseBody.result; //赋值表格
                that.page.total= res.data.responseBody.pageParameter.totalCount//重新赋值分页
            });

        }
    },
    //监听,界面初始化执行下面方法
    mounted(){
        //接收查询界面查询参数
        this.$bus.$on("receiveQueryParam",(queryParam)=>{
            console.log("queryParam",queryParam);
            this.queryParam = queryParam;
            this.$options.methods.query.bind(this)();//执行查询
        });

        //进入界面执行
        this.$options.methods.query.bind(this)();//执行查询

    }
  }



</script>